<?php


if (isset($_GET['minified']) && $_GET['minified'] == 'true'){

	$scriptTags = '<script type="text/javascript" src="out/all.js"></script>';

} else {

	$jsListFile = 'js-list.txt';


	$fp = fopen($jsListFile, 'r');
	$contents = fread ( $fp , filesize($jsListFile) );
	fclose($fp);


	/**
	 *	create js contents
	 */
	$scriptTags = preg_replace(

		array(

			"/^\;.*$/m",

			"/^\s*(\r\n|\n)$/m",

			"/[\r\n]+/m",

			"/^(.+)$/m",

		),

		array(

			"",

			"",

			"\n",

			'<script type="text/javascript" src="src/$1"></script>'

		),

		$contents

	);

}


/**
 *	create nodes
 */
$contents = '';

$template = '<div{attr}>{content}</div>';

$count = 50;

for($c = 0; $count--;){

	$c++;

	$replacements = array(

		'/\{attr\}/' => ' class="ct count' . $c . '" id="id' . $c . '" name="name' . $c . '" test="test"',

		'/\{content\}/' => '
		row ' . $c . '
		<span>test span</span>
		<br />
		<b lang="fr" id="fr' . $c .'">test b</b>
		<br />
		test textnode
		<div lang="fr-be"  id="fr-be' . $c .'">
			<span>inner span</span>

			<hr />
		</div>
		',

	);

	$contents .= preg_replace(

		array_keys( $replacements ),

		array_values( $replacements ),

		$template

	);

}

$contents = '<div id="query-sample">' . $contents . '</div>';


/**
 *	output HTML
 */
echo <<<HTMLDOC
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Jx</title>
	<!-- <link rel="stylesheet" type="text/css" href="styles/base/jx.css" /> -->

{$scriptTags}

	<script type="text/javascript" src="ext-all-debug.js"></script>

</head>
<body style="margin: 10px 20px 30px 40px">

	{$contents}


	<script type="text/javascript" src="test.js" checked="checked"></script>




</body>
</html>

HTMLDOC;
